<HTML>
<HEAD>
<TITLE>Teleports</TITLE>
</head>

<body>

<center>
<h1>BOI 2001 Day 2 Problem 3</h1>
<h1>Teleports</h1>
</center>

<p>
Great sorcerer Byter created two islands on the Baltic See:  Bornholm and Gotland.
On each island he has installed some magical teleports.
Each teleport can work in one of two modes:   
<ul>  
<li> receiving--one can be teleported to it,   
<li> sending--anyone who enters the teleport is transfered to  the specific destination teleport on the other island,  provided that the other  teleport is in the receiving mode.
</ul>
<p>
Once, Byter gave his apprentices the following task:  they must set the teleports' modes in such a way, that no teleport  is useless, i.e.
for each teleport set in the receiving mode  there must be at least one teleport sending to it, set in the sending mode;   and vice versa, for each teleport set in the sending mode, the  destination teleport must be set in the receiving mode.

<h2>Task</h2>
Write a program that:
<ul>  
<li> reads the description of the teleports on both islands,  form the input file <tt>tel.in</tt>,  
<li> determines the appropriate modes for teleports,   
<li> writes the result to the output file <tt>tel.out</tt>.
</ul>
<p>
If there are several possible solutions, your program should  output just one of them.</p>

<h2>Input</h2>
In the first line of the text file <tt>tel.in</tt>, there are two  integers <i>m</i> and <i>n</i>, <i>1&lt;=m,n&lt;=50&nbsp;000</i>,  separated by a single space;  <i>m</i> is the number of teleports on Bornholm, and  <i>n</i> is the number of teleports on Gotland.
Teleports on both islands are numbered from 1 to <i>m</i> and <i>n</i>  respectively.
The second line of the file contains <i>m</i> positive integers, not  greater than <i>n</i>, separated by single spaces--<i>k</i>-th of these  integers is the number of the teleport on Gotland that is the  destination of the teleport <i>k</i> on Bornholm.
The third line contains analogous data for teleports on Gotland,  i.e.
<i>n</i> positive integers, not greater than <i>m</i>,separated by  single spaces--<i>k</i>-th of these integers is the number of the  teleport on Bornholm that is the destination of the teleport  <i>k</i> on Gotland.

<h2>Output</h2>
Your program should write two lines describing the modes of the  teleports, respectively, on Bornholm and Gotland,  to the output file <tt>tel.out</tt>.
Both lines should contain a string of, respectively, <i>m</i> or <i>n</i>  ones and/or zeros.
If the <i>k</i>-th character in the string is <tt>1</tt>, then the  <i>k</i>-th teleport is in the sending mode, and if it is <tt>0</tt>,  than the corresponding teleport is in the receiving mode.

<h2>Sample Input</h2>
<pre>
4 5
3 5 2 5
4 4 4 1 3
</pre>

<h2>Sample Output</h2>
<pre>
0110
10110
</pre>

<h2>Figures</h2>
<center>
<p><img src="image/282a.gif">
<p><img src="image/282b.gif">
</center>

</body>
</html>
